package com.learn.zzy.autogeneration.complier.bms;

import com.learn.zzy.autogeneration.complier.bms.annotation.SerializeZzy;


import java.util.List;
import java.util.Set;

import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement;
import javax.lang.model.util.Elements;

@SupportedAnnotationTypes({"com.learn.zzy.autogeneration.complier.bms.annotation.*"})
public class MyProcessor extends AbstractProcessor {

    // 元素操作的辅助类
    Elements elementUtils;

    @Override
    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
        System.out.println("---------myProcessor-------------");
        Set<? extends Element> elements = roundEnv.getElementsAnnotatedWith(SerializeZzy.class);
        TypeElement classElement = null;//生命类元素
        List<VariableElement> fileds = null;//生命一个存放成员变量的列表
        return false;
    }

    @Override
    public synchronized void init(ProcessingEnvironment processingEnv) {
        super.init(processingEnv);
        elementUtils = processingEnv.getElementUtils();
        System.out.println("---------myProcessor-------------");
    }

    @Override
    public Set<String> getSupportedAnnotationTypes() {
        return super.getSupportedAnnotationTypes();
    }

    @Override
    public SourceVersion getSupportedSourceVersion() {
        return SourceVersion.latestSupported();
    }
}
